<?php
namespace Mobile\Controller;
use Think\Controller;
class SearchController extends Controller {
    //文章url
    public static function url($list){
        //获取操作模块名
        $m=MODULE_NAME;
        foreach($list as $k=>$v){
            if(strstr("{$list[$k]['url']}","index?")){
                //动态地址
                $list[$k]['url']="/".$m.$list[$k]['url'];
            }else{
                if($m=="Home"){
                    //静态地址
                    $list[$k]['url']="/www/".$list[$k]['url'];
                }else{
                    //静态地址
                    $list[$k]['url']="/m/".$list[$k]['url'];
                }
                
            }
        }
        return $list;
    }
    public function index(){
        $com=M("configs")->where("name='CFG_WEBNAME'")->getField("value");
        $catename=$_POST['catename'];
        $keywords=$_POST['keywords']; 
        $modelid=M("category")->where("catename='{$catename}'")->getField("modelid");
        $cateid=M("category")->where("catename='{$catename}'")->getField("cateid");
        $table=M("model")->where("modelid=$modelid")->getField("table");
        $tablename="model_".$table;
        $where = array('catid' => $cateid,'keywords' => array("like","%$keywords%"));
        $listinfo=M("$tablename")->where($where)->select();
        $listinfo=self::url($listinfo);
        $title="搜索中心";
        $this->assign("listinfo",$listinfo);
        $this->assign("com",$com);
        $this->assign("title",$title);
        $this->display("./List_search");
    }  

}